<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
	<meta charset="UTF-8">
	<title>应急调度管理</title>
	<link rel="stylesheet" href="/lib/layui/layui/css/layui.css">
	<script type="text/javascript" src="/lib/layui/layui.js"></script>
	<script type="text/javascript" src="/lib/jquery-2.1.4.min.js"></script>
	<%--<script type="text/javascript" src="/lib/layui/layui.all.js"></script>--%>
	<script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
	<script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>

	<script type="text/javascript" src="/lib/layer/layer.js?20201106"></script>
	<script type="text/javascript" src="/lib/layui/layui/lay/mymodules/soulTable.js"></script>
	<script type="text/javascript" src="/lib/layui/layui/lay/mymodules/tableFilter.js"></script>
	<script type="text/javascript" src="/lib/layui/layui/lay/mymodules/excel.js"></script>
	<script type="text/javascript" src="/lib/layui/layui/lay/mymodules/tableChild.js"></script>
	<script type="text/javascript" src="/lib/layui/layui/lay/mymodules/tableMerge.js"></script>
	<script type="text/javascript" src="/lib/layui/layui/global.js"></script>
	<script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>


	<style>
		.soul-bottom-contion{
			display: none;
		}
		.layui-tab-title{
			display: none;
		}
		.soul-filter-listmyTable{
			display: none;
		}
		* {font-family: "Microsoft Yahei" !important;}
		.add{
			margin-top: 10px;
			margin-left: 10px;
		}
		.layui-layer-btn .layui-layer-btn1{
			background: #009688;
			color: #fff;
		}
		/*#Settlement{*/
		/*table-layout: fixed;*/
		/*border-collapse: collapse;*/
		/*width: 100%;*/
		/*}*/
		.layui-body{overflow-y: scroll;}
		/*#pensons .layui-table-cell {*/
			/*font-size:14px;*/
			/*padding:0 5px;*/
			/*height:auto;*/
			/*overflow:visible;*/
			/*text-overflow:inherit;*/
			/*white-space:normal;*/
			/*word-break: break-all;*/
			/*text-align: center;*/
		/*}*/
		.th{
			color: #555;
			font-weight: normal;
		}
        .red{
            color: red;
        }
      .layui-table-header .layui-table  th[data-field="0"]{
            width: 65px !important;
        }
	  .childTr  .layui-tab-content .layui-table-box  .layui-table-fixed{
		  width: 55px;
	  }
	  div[lay-filter="LAY-table-1"]  .layui-table-box .layui-table-header  .layui-table{
			width: 100%;
		}
		div[lay-filter="LAY-table-1"]  .layui-table-box .layui-table-body .layui-table{
			width: 100%;
		}
        .layui-table-body  .layui-table  th[data-field="0"] .layui-table-cell{
            width: 47px !important;
        }
        #pensons .layui-table-header .layui-table{
            width: 100% !important;
        }
        #pensons .layui-table-body .layui-table{
            width: 100% !important;
        }
        .wz  .layui-table-view  .layui-table-box .layui-table{
            width: 100%;
        }
		.childTr  .layui-tab-content  .layui-table-box  .layui-table-header  .layui-table{
			width: 100%;
		}
		.childTr  .layui-tab-content  .layui-table-box  .layui-table-body  .layui-table{
			width: 100%;
		}
		.childTr .layui-table thead tr{
			background-color: #D3EAEF;
		}
		.childTr  .layui-tab-card  .layui-tab-content  .layui-table-view  .layui-table-box  .layui-table-body  {
			height: auto !important;
		}
		div[lay-filter="LAY-table-1"] {
			margin: 10px 7px;
		}
		.layui-table-box .layui-table-body{
			overflow: inherit;
		}
		#pensons .layui-table-box .layui-table-body{
			overflow: auto;
		}
		.no:hover{
			cursor:no-drop
		}
	</style>

	<link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<button type="button" class="layui-btn  layui-btn-norma add" id="add">添加救援事件</button>
<table id="myTable" lay-filter="myTable" lay-data="{id: 'idTest'}"></table>

<%--导出物资详情的表格数据--%>
<div class="aa" style="display: none">
	<table  style="margin: 0 auto;width:100%;font-weight: normal;font-family: '宋 体';	border-collapse:collapse" class="tr_td tr_tds" border="1">
		<thead>
        <tr class="wuzi">

        </tr>
		<tr>
			<th style="color: #555;font-weight: normal;">
				设备名称
			</th>
			<th  style="color: #555;font-weight: normal;">
				型号
			</th>
			<th  style="color: #555;font-weight: normal;">
				设备类别
			</th>
            <th  style="color: #555;font-weight: normal;">
                所在位置
            </th>
            <th  style="color: #555;font-weight: normal;">
                数量
            </th>
		</tr>
		</thead>
		<tbody>

		</tbody>
	</table>
</div>
<%--导出人员详情的表格数据--%>
<div class="bb" style="display:none">
	<table  style="margin: 0 auto;width:100%;font-weight: normal;font-family: '宋 体';	border-collapse:collapse" class="tr_td tr_tds fren" border="1">
		<thead>
		<tr class="renyuan">

		</tr>
		<tr>
			<th style="color: #555;font-weight: normal;" rowspan="2">
				姓名
			</th>
			<th  style="color: #555;font-weight: normal;" rowspan="2">
				岗位
			</th>
			<th  style="color: #555;font-weight: normal;"rowspan="2">
				联系电话
			</th>
			<th  style="color: #555;font-weight: normal;" rowspan="2" >
				身份证号
			</th>
			<th  style="color: #555;font-weight: normal;" class="zjNum" colspan="4">
				国际救援证件
			</th>
		</tr>
		<tr class="bt">

		</tr>
		</thead>
		<tbody>

		</tbody>
	</table>
</div>

<%--</script>--%>
<script>
	var jyuan=""
	layui.use(['form', 'table','soulTable'], function () {
		var table = layui.table
			var	soulTable = layui.soulTable;
		var laydate = layui.laydate;
		table.render({
			elem: '#myTable'
			,url: '/crashParent/showAll'
			// ,height:1000
			,page: false
			,cols: [[
				{title: '#'
                ,isChild: function(d){
            // row 为当前行数据，根据返回结果控制是否展示子表入口
            // console.log(d)
            return  d.crashDispatchList!= undefined
        }
        ,children:[
						{
							url: '/crashParent/showCrashDispById'
							,page: false
							,where:function(d){
								return {crasPareId: d.crasPareId}
							}
							,cols: [[
								{type: 'checkbox', fixed: 'left'},
								{field: 'eventName', title: '任务名称', width: '8.5%', filter: true},
								{field: 'happenTime', title: '发生时间', width: '13.5%',  filter: true},
								{field: 'happenPlace', title: '发生地点', width: '8.5%' , filter: true},
								{field: 'eventDescribe', title: '任务描述', width: '14%', filter: true},
								{field: 'rescueUserName', title: '领导小组', width: '12.2%',},
								{field: 'reactionUserName', title: '执行小组', width: '12%',},
								{title: '操作', width: '28%', templet: function(row) {
                                        return '<a class="layui-btn layui-btn-norma layui-btn-xs" lay-event="upd">修改</a>' +
                                            '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="people">人员详情</a>'+
                                            '<a class="layui-btn layui-btn-danger layui-btn-xs thingdet" lay-event="thing">物资详情</a>'+
                                            '<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="rd" style="background: #b21fef;">救援调度</a>'+
                                            '<a class="layui-btn layui-btn-norma layui-btn-xs" lay-event="dele">删除</a>'
                                    }}
							]]
                            ,toolEvent: function (obj) {
                                var data = obj.data;
                                // console.log(data)
                                var childId = this.id; // 通过 this 对象获取当前子表的id
                                //修改
                                if(obj.event === 'upd'){
                                    //点击修改按钮 回显数据的接口
                                    $.ajax({
                                        url:'/crash/showDetails',
                                        type: 'get',
                                        dataType: 'json',
                                        data:{crasId:data.crasId},
                                        success:function (res) {
                                            $("#information").val(res.obj.eventName);
                                            $("#yzdata").val(res.obj.happenTime);
                                            $("#place").val(res.obj.happenPlace)
                                            $("#rescueUser").val(res.obj.rescueUserName);
                                            $("#rescueUser").attr('username',res.obj.rescueUserName);
                                            $("#rescueUser").attr('dataid',res.obj.rescueUser);
											$("#rescueExecute").val(res.obj.reactionUserName);
											$("#rescueExecute").attr('username',res.obj.reactionUserName);
											$("#rescueExecute").attr('dataid',res.obj.reactionUser);
                                            $("#infoms").val(res.obj.eventDescribe)
                                        }
                                    });
                                    layer.open({
                                        type: 1 //Page层类型
                                        ,area: ['900px', '500px']
                                        ,title: '修改救援事件'
                                        ,shade: 0.6 //遮罩透明度
                                        ,maxmin: true //允许全屏最小化
                                        ,content: htmlpoen
                                        ,btn: ['保存', '取消']
                                        ,yes: function(index, layero){

                                            var info = $('#information').val()
                                            var yz = $('#yzdata').val()
                                            var dir = $('#place').val()
                                            var discr = $('#infoms').val()
                                            var user = $('#rescueUser').attr('username')
                                            var idss = $('#rescueUser').attr('dataid')
											 var userExecute=$('#rescueExecute').attr('username')
											 var idssExecute=$('#rescueExecute').attr('dataid')
                                            var param={
                                                crasId:data.crasId,
                                                eventName:info,
                                                happenTime:yz,
                                                happenPlace:dir,
                                                eventDescribe:discr,
                                                rescueUser:idss,
                                                rescueUserName:user,
												reactionUser:idssExecute,
												reactionUserName:userExecute
                                            }
                                            $.ajax({
                                                url:'/crash/change',
                                                type: 'post',
                                                dataType: 'json',
                                                data:param,
                                                success:function (res) {
                                                    layer.closeAll()
                                                    table.reload(childId)
                                                }
                                            });

                                        }
                                        ,success:function(e){
                                            //显示时间
                                            laydate.render({
                                                elem:'#yzdata'
                                                ,trigger: 'click'//呼出事件改成click
                                                ,type:'datetime'
                                                ,format: 'yyyy-MM-dd HH:mm:ss'
                                            });
                                            //点击添加的按钮
                                            $(".addjy").on("click",function(){
                                                user_id = "rescueUser";
                                                $.popWindow("/common/selectUser");
                                            });
                                            //点击清空的按钮
                                            $('.clear').click(function () {
                                                $("#rescueUser").val("");
                                                $("#rescueUser").attr('username','');
                                                $("#rescueUser").attr('dataid','');
                                                $("#rescueUser").attr('user_id','');
                                                $("#rescueUser").attr('userprivname','');
                                            });
											//点击添加的按钮
											$(".addExecute").on("click",function(){
												user_id = "rescueExecute";
												$.popWindow("/common/selectUser");
											});
											//点击清空的按钮
											$('.clearExecute').click(function () {
												$("#rescueExecute").val("");
												$("#rescueExecute").attr('username','');
												$("#rescueExecute").attr('dataid','');
												$("#rescueExecute").attr('user_id','');
												$("#rescueExecute").attr('userprivname','');
											});
                                        }
                                    });
                                }
                                //救援调度
                                else if(obj.event === 'rd'){
                                    jyuan=data;
                                    layer.open({
                                        title: '救援调度'
                                        ,type: 2 //Page层类型
                                        ,maxmin: true //允许全屏最小化
                                        , skin: 'layui-layer-rim' //加上边框
                                        , area: ['100%', '100%'] //宽高
                                        ,content:'/crash/intRescueTeam'
                                    });
                                }
                                //删除
                                else if(obj.event === 'dele'){
                                    layer.confirm('确定要删除这个任务吗？', {icon: 3, title:'提示'}, function(index){
                                        $.ajax({
                                            url:'/crash/delete',
                                            type: 'post',
                                            dataType: 'json',
                                            data:{crasId:data.crasId},
                                            success:function(){
                                                table.reload(childId)
                                                window.location.reload()
                                            }
                                        });
                                        layer.close(index);
                                    });
                                }
                                //人员详情
                                else if(obj.event === 'people'){
                                    layer.open({
                                        type: 1 //Page层类型
                                        ,area: ['100%', '100%']
                                        ,title: '人员详情'
                                        ,shade: 0.6 //遮罩透明度
                                        ,maxmin: true //允许全屏最小化
                                        ,content: '<div id="pensons">' +
												'<button type="button" class="layui-btn layui-btn-sm sure" >确认人员已到位</button>'+
												'<table class="layui-table fren" style="margin-top: 0px;">' +
												' <thead>\n' +
												'    <tr>\n' +
												'      <th rowspan="2">姓名</th>\n' +
												'      <th rowspan="2">岗位</th>\n' +
												'      <th rowspan="2">联系电话</th>\n' +
												'      <th rowspan="2">身份证号</th>\n' +
												'      <th class="zjNum" colspan="4">国际救援证件</th>\n' +
												'    </tr> \n' +
												'    <tr class="bt">\n' +
												'      <th>证件名称</th>\n' +
												'      <th>证件编号</th>\n' +
												'      <th>发证机构</th>\n' +
												'      <th>截止日期</th>\n' +
												'    </tr> \n' +
												'  </thead>'+
												'<tbody>'+
												'    <tr >\n' +
												'      <td></td>\n' +
												'      <td></td>\n' +
												'      <td></td>\n' +
												'      <td></td>\n' +
												'    </tr> \n' +
												'</tbody>'+
												'</table>' +
												'</div>'
                                        ,btn: ['打印','导出PDF','取消']
                                        ,yes: function(index, layero){
                                            $('.layui-layer-btn').css('display','none')
                                            window.print()
                                            $('.layui-layer-btn').css('display','block')

                                        }
                                        ,btn2:function (index) {
                                            var width =$('.layui-layer-content').width()
                                            $.ajax({
                                                url:'/crash/toPDF',
                                                type:'post',
                                                data:{
                                                    htmlContent:$('.bb').html(),
                                                    width:width
                                                },
                                                dataType:'json',
                                                success:function (data){
                                                    var attUrl = data.object.attUrl;
                                                    window.open('/download?'+attUrl);
                                                }
                                            })
                                            return false
                                        }
                                        ,success:function (res) {
                                            var crasId=data.crasId;
                                            var strs='';
											var flength=''
                                            $.get('/crash/showDetails',{crasId:crasId, type:1},function (rese) {
												if(rese.obj.eventState==1){
													$('.sure').html('人员已确定')
													$('.sure').attr('disabled','true')
													$('.sure').addClass('no')

												}else if(rese.obj.eventState==0){
													$('.sure').html('确认人员到位')
												}
												var fdata=rese.obj.rescuePersonList
												console.log(fdata)
												if(fdata==undefined){
													$('.sure').hide()
												}
                                                var  str1= '<td>项目名称:</td>'+
                                                    '<td >'+
                                                    function (){
                                                        if(rese.obj.eventName==undefined){
                                                            return  ''
                                                        }else{
                                                            return rese.obj.eventName
                                                        }
                                                    }()+'</td> ' +
                                                    '<td></td>'+
                                                    '<td>发生地点:</td>'+
                                                    '<td >'+
                                                    function (){
                                                        if(rese.obj.happenPlace==undefined){
                                                            return  ''
                                                        }else{
                                                            return rese.obj.happenPlace
                                                        }
                                                    }()+'</td>' +
                                                    '<td></td>'+
                                                    '<td>发生时间:</td>'+
                                                    '<td>'+
                                                    function (){
                                                        if(rese.obj.happenTime==undefined){
                                                            return  ''
                                                        }else{
                                                            return rese.obj.happenTime
                                                        }
                                                    }()+'</td>'+
                                                    '<td></td>'+
                                                    '<td>事件描述:</td>'+
                                                    '<td>'+
                                                    function (){
                                                        if(rese.obj.eventDescribe==undefined){
                                                            return  ''
                                                        }else{
                                                            return rese.obj.eventDescribe
                                                        }
                                                    }()+'</td>'
												if(fdata!==undefined){
													for(var i=0;i<fdata.length;i++){
														strs+=' <tr>\n' +
																'      <td>'+fdata[i].userName+'</td>\n' +  //姓名
																'      <td>'+fdata[i].jobName+'</td>\n' +     //岗位
																'      <td>'+fdata[i].mobilNo+'</td>\n' +    //联系电话
																'      <td>'+fdata[i].idNumber+'</td>\n' +   //身份证号
																function () {
																	var ss
																	var zjbt
																	flength+=fdata[i].hrphotoWithBLOBsList.length+','
																	if(fdata[i].hrphotoWithBLOBsList.length>0){
																		for(var j=0;j<fdata[i].hrphotoWithBLOBsList.length;j++){
																			zjbt+= '      <th>证件名称</th>\n' +
																					'      <th>证件编号</th>\n' +
																					'      <th>发证机构</th>\n' +
																					'      <th>截止日期</th>\n'
																			ss+='<td>'+function () {
																						if(fdata[i].hrphotoWithBLOBsList[j].licenseName==undefined || fdata[i].hrphotoWithBLOBsList[j].licenseName==''){
																							return   ''
																						}else{
																							return fdata[i].hrphotoWithBLOBsList[j].licenseName
																						}
																					}()+'</td>\n' +   //证件名称
																					'      <td>'+fdata[i].hrphotoWithBLOBsList[j].licenseNo+'</td>\n' +  //证件编号
																					'      <td>'+fdata[i].hrphotoWithBLOBsList[j].notifiedBody+'</td>\n' +   //发证机构
																					'      <td>'+fdata[i].hrphotoWithBLOBsList[j].getLicenseDate+'</td>\n'   //取证日期

																			$('.zjNum').attr('colspan',4*fdata[i].hrphotoWithBLOBsList.length)
																		}
																	}else{
																		var chang=flength.split(',')
																		var aa=chang.map(Number)
																		var max = Math.max.apply(null,aa);
																		console.log(max)
																		if(max==0){
																			ss+='<td></td>\n' +   //证件名称
																					'<td></td>\n' +  //证件编号
																					'<td></td>\n' +   //发证机构
																					'<td></td>\n'   //取证日期
																		}else {
																			for(var k=0;k<max;k++){
																				ss+='<td></td>\n' +   //证件名称
																						'<td></td>\n' +  //证件编号
																						'<td></td>\n' +   //发证机构
																						'<td></td>\n'   //取证日期
																			}
																		}


																	}


																	$('.bt').html(zjbt)

																	return ss
																}()+
																'    </tr>'
													}
												}else{
													strs+=''
												}


												$('.tr_tds .renyuan').html(str1)
												$('.fren tbody').html(strs)
                                            });
											$('.sure').click(function () {
												$.ajax({
													url:'/crash/confirmUsers',
													type:'post',
													data:{
														type:1,
														crasId:crasId
													},
													dataType:'json',
													success:function (data){
														console.log(data)
														if(data.msg=true){
															$('.sure').html('人员已确定')
															$('.sure').attr('disabled','true')
															$('.sure').addClass('no')
														}
													}
												})
											})

                                        }
                                    });

                                }
                                //物资详情
                                else if(obj.event === 'thing'){
                                    //物资详情的页面
                                    layer.open({
                                        type: 1 //Page层类型
                                        ,area: ['100%', '100%']
                                        ,title: '物资详情'
                                        ,shade: 0.6 //遮罩透明度
                                        ,maxmin: true //允许全屏最小化
                                        ,content: '<div class="wz"><table id="zSettlement1" lay-filter="SettlementFilter"></table></div>'
                                        ,btn: ['打印','导出PDF','取消']
                                        ,yes: function(index, layero){
                                            $('.layui-layer-btn').css('display','none')
                                            window.print()
                                            $('.layui-layer-btn').css('display','block')
                                        }
                                        ,btn2:function (index) {
                                            // 获取表单的最长宽度
                                            var width =$('.layui-layer-content').width()
                                            $.ajax({
                                                url:'/crash/toPDF',
                                                type:'post',
                                                data:{
                                                    htmlContent:$('.aa').html(),
                                                    width:width
                                                },
                                                dataType:'json',
                                                success:function (data){
                                                    var attUrl = data.object.attUrl;
                                                    window.open('/download?'+attUrl);
                                                }
                                            })
                                            return false
                                        }
                                        ,success:function (res) {
                                            var crasId=data.crasId;
                                            $.get('/crash/showDetails',{crasId:crasId, type:2},function (re) {
                                                var data;
                                                var  str1= '<td >'+'项目名称:'+
                                                    function (){
                                                        if(re.obj.eventName==undefined){
                                                            return  ''
                                                        }else{
                                                            return re.obj.eventName
                                                        }
                                                    }()+'</td> ' +
                                                    '<td >'+'发生地点:'+
                                                    function (){
                                                        if(re.obj.happenPlace==undefined){
                                                            return  ''
                                                        }else{
                                                            return re.obj.happenPlace
                                                        }
                                                    }()+'</td>' +
                                                    '<td>'+'发生时间:'+
                                                    function (){
                                                        if(re.obj.happenTime==undefined){
                                                            return  ''
                                                        }else{
                                                            return re.obj.happenTime
                                                        }
                                                    }()+'</td>'+
                                                    '<td>'+'事件描述:'+
                                                    function (){
                                                        if(re.obj.eventDescribe==undefined){
                                                            return  ''
                                                        }else{
                                                            return re.obj.eventDescribe
                                                        }
                                                    }()+'</td>'
                                                if(re.obj.rescueEquipmentList!=undefined){
                                                    data=re.obj.rescueEquipmentList;
                                                }else{
                                                    data=[]
                                                }

                                                var str = '';
                                                var tab1=table.render({
                                                    elem: '#zSettlement1'
                                                    ,data:data
                                                    ,cols: [[
                                                        {field:'assetsName', title:'设备名称',width:'20%'}
                                                        ,{field:'info', title:'型号',width:'20%'}
                                                        ,{field:'typeName', title:'设备类别',width:'20%'}
                                                        ,{field:'currutLocation', title:'所在位置',width:'20%'}
                                                        ,{field:'number', title:'数量',width:'20%'}
                                                    ]]
                                                    ,done:function (res) {
                                                        for(var i=0;i<res.data.length;i++){
                                                            str+='<tr>' +
                                                                '<td style="text-align: center">'+res.data[i].assetsName+'</td> ' +
                                                                '<td style="text-align: center">'+res.data[i].info+'</td>' +
                                                                '<td style="text-align: center">'+res.data[i].typeName+'</td>' +
                                                                '<td style="text-align: center">'+res.data[i].currutLocation+'</td>' +
                                                                '<td style="text-align: center">'+res.data[i].number+'</td>' +
                                                                '</tr>'
                                                        }
                                                        $('.tr_tds tbody').html(str);
                                                        $('.tr_tds .wuzi').html(str1);

                                                    }
                                                    ,page: true,
                                                })
                                            });
                                            $('.layui-table-view .layui-table').css('width','none')

                                        }
                                    });
                                }
                                table.reload(this.id)
                            }
							,done: function () {
								soulTable.render(this)
							}
						}
					]},
				{field: 'eventName', title: '事件名称', width:'8%'},
				{field: 'happenTime', title: '发生时间', width: '13%',templet: function(d){
			return   timestampToTime1(d.happenTime)
		}},
				{field: 'happenPlace', title: '发生地点', width: '8%'},
				{field: 'eventDescribe', title: '事件描述', width: '14%'},
				{field: 'rescueUserName', title: '应急反应领导小组', width: '11.5%',},
				{field: 'reactionUserName', title: '应急反应执行小组', width: '11.5%',},
				{title: '操作', width: '29.3%', templet: function(row) {
				    // console.log(row)
                        if(row.crasId=='' || row.crasId==undefined){
                            return   '<a class="layui-btn layui-btn-xs" lay-event="add">添加任务</a>'
                        }else{
                            return '<a class="layui-btn layui-btn-xs" lay-event="add">添加任务</a>'+
                            '<a class="layui-btn layui-btn-norma layui-btn-xs" lay-event="upd">修改</a>' +
                                '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="people">人员详情</a>'+
                                '<a class="layui-btn layui-btn-danger layui-btn-xs thingdet" lay-event="thing">物资详情</a>'+
                                '<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="rd" style="background: #b21fef;">救援调度</a>'+
                                '<a class="layui-btn layui-btn-norma layui-btn-xs" lay-event="dele">删除</a>'


                        }

                    }}
			]]
			,done: function (res) {
				soulTable.render(this)
			}
            ,parseData: function(res){ //res 即为原始返回的数据
			    // console.log(res)
                if(res.msg=='err'){
                    msg='无数据'
                    return {
                        "msg":msg , //解析提示文本
                    };
                }else{
                    return {
                        "code": 0, //解析接口状态
                        "data": res.data //解析数据列表
                    };
                }

            }
		});

		//监听父表工具条
		table.on('tool(myTable)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
			var data = obj.data; //获得当前行数据
			var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
			var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
			// console.log(data)
			var crasPareId=data.crasPareId
            //添加子任务
			if(layEvent === 'add'){
				layer.open({
					type: 1 //Page层类型
					,area: ['900px', '550px']
					,title: '添加任务'
					,shade: 0.6 //遮罩透明度
					,maxmin: true //允许全屏最小化
					,content: '<div>' +
							'			<form class="layui-form" action="">\n' +
							' <div class="layui-form-item" style="margin-top:10px">\n' +
							'<label class="layui-form-label">任务名称<b class="red">*</b>'+'</label>\n' +
							'<div class="layui-input-block">\n' +
							'<input type="text" name="eventName" id="information" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:50%">\n' +
							'</div>\n' +
							'</div>' +
							'<div class="layui-inline">\n' +
							'<label class="layui-form-label" style="margin-bottom:15px">发生时间<b class="red">*</b>'+'</label>\n' +
							'<div class="layui-input-inline">\n' +
							'<input type="datetime" name="happenTime" id="yzdata"  autocomplete="off" class="layui-input">\n' +
							'</div>\n'+
							'</div>' +
							'<div class="layui-form-item">\n' +
							'<label class="layui-form-label">发生地点<b class="red">*</b>'+'</label>\n' +
							'<div class="layui-input-block" style="margin-bottom:"15px">\n' +
							'<input type="text" name="happenPlace"  id="place" required  lay-verify="required"  autocomplete="off" class="layui-input" style="width:50%">\n' +
							'</div>'+
							'</div>\n' +
							'<div class="layui-inline" style="width:97%; margin: 15px 0;">\n' +
							'<label class="layui-form-label" style="width:68px;margin-top:-9px;margin-left:13px;">应急反应领导小组<b class="red">*</b>'+'</label>\n' +
							'<div class="layui-input-inline" style="width:72%">\n' +
							'<textarea type="text" id="rescueUser" name="rescueUserName"  autocomplete="off" class="layui-input" disabled></textarea>\n' +
							'<input type="hidden"  name="electivePerson" placeholder="" autocomplete="off" class="layui-input">\n'+
							'<div style="float:right;margin: -29px -72px 0px 0px;color:#1E9FFF"><a href="javascript:;" style="color:#1E9FFF" class="addjy">添加</a>\n' +
							'<a href="javascript:;" style="color:#1E9FFF" class="clear">清空</a>' +
							'</div>\n' +
							'</div>\n' +
							'</div>\n'+
							'<div class="layui-inline" style="width:97%; margin: 15px 0;">\n' +
							'<label class="layui-form-label" style="width:68px;margin-top:-9px;margin-left:13px;">应急反应执行小组<b class="red">*</b>'+'</label>\n' +
							'<div class="layui-input-inline" style="width:72%">\n' +
							'<textarea type="text" id="rescueExecute" name="rescueExecute"  autocomplete="off" class="layui-input" disabled></textarea>\n' +
							'<input type="hidden"  name="electivePerson" placeholder="" autocomplete="off" class="layui-input">\n'+
							'<div style="float:right;margin: -29px -72px 0px 0px;color:#1E9FFF"><a href="javascript:;" style="color:#1E9FFF" class="addExecute">添加</a>\n' +
							'<a href="javascript:;" style="color:#1E9FFF" class="clearExecute">清空</a>' +
							'</div>\n' +
							'</div>\n' +
							'</div>\n'+
							'<div class="layui-form-item layui-form-text">\n' +
							'<label class="layui-form-label">任务描述</label>\n' +
							'<div class="layui-input-block">\n' +
							'<textarea name="eventDescribe"  id="infoms" class="layui-textarea" style="width:81%"></textarea>\n' +
							'</div>\n' +
							'</div>\n' +
							'</form>' +
							'</div>'
					,btn: ['保存', '取消']
					,yes: function(index, layero){
						var info = $('#information').val()
						var yz = $('#yzdata').val()
						var dir = $('#place').val()
						var discr = $('#infoms').val()
						var user = $('#rescueUser').attr('username')
						var idss = $('#rescueUser').attr('dataid')
						var userExecute = $('#rescueExecute').attr('username')
						var idssExecute = $('#rescueExecute').attr('dataid')
                        if(info==''){
                            layer.msg('请填写任务名称！', {icon: 5});
                            return false
                        }
                        if(yz==''){
                            layer.msg('请填写发生时间！', {icon: 5});
                            return false
                        }
                        if(dir==''){
                            layer.msg('请填写发生地点！', {icon: 5});
                            return false
                        }
                        if(user=='' || user==undefined){
                            layer.msg('请选择应急反应领导小组！', {icon: 5});
                            return false
                        }
						if(userExecute=='' || userExecute==undefined){
							layer.msg('请选择应急反应执行小组！', {icon: 5});
							return false
						}
						param={
							eventName:info,
							happenTime:yz,
							happenPlace:dir,
							eventDescribe:discr,
							rescueUser:idss,
							rescueUserName:user,
							pareId:crasPareId,
							reactionUser:idssExecute,
							reactionUserName:userExecute
						},
								$.ajax({
									url:'/crash/add',
									type: 'post',
									dataType: 'json',
									data:param,
									success:function (res) {
										// table.reload()
										layer.closeAll()
                                        window.location.reload()
									}
								});

					}
					,success:function(e){
						$.ajax({
							url:'/crash/getLastDisp',
							type: 'post',
							dataType: 'json',
							success:function (res) {
								$('#rescueUser').val(res.obj.rescueUserName)
								$('#rescueUser').attr('username',res.obj.rescueUserName)
								$('#rescueUser').attr('dataid',res.obj.rescueUser)
								$('#rescueExecute').val(res.obj.reactionUserName)
								$('#rescueExecute').attr('username',res.obj.reactionUserName)
								$('#rescueExecute').attr('dataid',res.obj.reactionUser)
							}
						});
						//显示时间
						laydate.render({
							elem:'#yzdata'
							,trigger: 'click'//呼出事件改成click
							,type:'datetime'
							,format: 'yyyy-MM-dd HH:mm:ss'
							// value:new Date()
						});
						//点击添加的按钮
						$(".addjy").on("click",function(){
							user_id = "rescueUser";
							$.popWindow("/common/selectUser");
						});
						//点击清空的按钮
						$('.clear').click(function () {
							$("#rescueUser").val("");
							$("#rescueUser").attr('username','');
							$("#rescueUser").attr('dataid','');
							$("#rescueUser").attr('user_id','');
							$("#rescueUser").attr('userprivname','');
						});
						//点击添加的按钮
						$(".addExecute").on("click",function(){
							user_id = "rescueExecute";
							$.popWindow("/common/selectUser");
						});
						//点击清空的按钮
						$('.clearExecute').click(function () {
							$("#rescueExecute").val("");
							$("#rescueExecute").attr('username','');
							$("#rescueExecute").attr('dataid','');
							$("#rescueExecute").attr('user_id','');
							$("#rescueExecute").attr('userprivname','');
						});

					}
				});
			}
            //修改
            else if(layEvent === 'upd'){
                //点击修改按钮 回显数据的接口
                $.ajax({
                    url:'/crash/showDetails',
                    type: 'get',
                    dataType: 'json',
                    data:{crasId:data.crasId},
                    success:function (res) {
                        $("#information").val(res.obj.eventName);
                        $("#yzdata").val(res.obj.happenTime);
                        $("#place").val(res.obj.happenPlace)
						$("#rescueUser").val(res.obj.rescueUserName);
						$("#rescueUser").attr('username',res.obj.rescueUserName);
						$("#rescueUser").attr('dataid',res.obj.rescueUser);
						$("#rescueExecute").val(res.obj.reactionUserName);
						$("#rescueExecute").attr('username',res.obj.reactionUserName);
						$("#rescueExecute").attr('dataid',res.obj.reactionUser);
                        $("#infoms").val(res.obj.eventDescribe)
                    }
                });
                layer.open({
                    type: 1 //Page层类型
                    ,area: ['900px', '500px']
                    ,title: '修改救援事件'
                    ,shade: 0.6 //遮罩透明度
                    ,maxmin: true //允许全屏最小化
                    ,content: htmlpoen
                    ,btn: ['保存', '取消']
                    ,yes: function(index, layero){

                        var info = $('#information').val()
                        var yz = $('#yzdata').val()
                        var dir = $('#place').val()
                        var discr = $('#infoms').val()
                        var user = $('#rescueUser').attr('username')
                        var idss = $('#rescueUser').attr('dataid')
						var userExecute=$('#rescueExecute').attr('username')
						var idssExecute=$('#rescueExecute').attr('dataid')
                        var param={
                            crasId:data.crasId,
                            eventName:info,
                            happenTime:yz,
                            happenPlace:dir,
                            eventDescribe:discr,
                            rescueUser:idss,
                            rescueUserName:user,
							reactionUser:idssExecute,
							reactionUserName:userExecute
                        }
                        $.ajax({
                            url:'/crash/change',
                            type: 'post',
                            dataType: 'json',
                            data:param,
                            success:function (res) {
                                // table.reload()
                                layer.closeAll()
                                window.location.reload()
                            }
                        });
                    }
                    ,success:function(e){
                        //显示时间
                        laydate.render({
                            elem:'#yzdata'
                            ,trigger: 'click'//呼出事件改成click
                            ,type:'datetime'
                            ,format: 'yyyy-MM-dd HH:mm:ss'
                        });
                        //点击添加的按钮
                        $(".addjy").on("click",function(){
                            user_id = "rescueUser";
                            $.popWindow("/common/selectUser");
                        });
                        //点击清空的按钮
                        $('.clear').click(function () {
                            $("#rescueUser").val("");
                            $("#rescueUser").attr('username','');
                            $("#rescueUser").attr('dataid','');
                            $("#rescueUser").attr('user_id','');
                            $("#rescueUser").attr('userprivname','');
                        });
						//点击添加的按钮
						$(".addExecute").on("click",function(){
							user_id = "rescueExecute";
							$.popWindow("/common/selectUser");
						});
						//点击清空的按钮
						$('.clearExecute').click(function () {
							$("#rescueExecute").val("");
							$("#rescueExecute").attr('username','');
							$("#rescueExecute").attr('dataid','');
							$("#rescueExecute").attr('user_id','');
							$("#rescueExecute").attr('userprivname','');
						});
                    }
                });
            }
            //救援调度
            else if(layEvent === 'rd'){
                jyuan=data;
                layer.open({
                    title: '救援调度'
                    ,type: 2 //Page层类型
                    ,maxmin: true //允许全屏最小化
                    , skin: 'layui-layer-rim' //加上边框
                    , area: ['100%', '100%'] //宽高
                    ,content:'/crash/intRescueTeam'
                });
            }
            //删除
            else if(layEvent === 'dele'){

                layer.confirm('确定要删除这个任务吗？', {icon: 3, title:'提示'}, function(index){
                    $.ajax({
                        url:'/crash/delete',
                        type: 'post',
                        dataType: 'json',
                        data:{crasId:data.crasId},
                        success:function(){
                            window.location.reload()
                        }
                    });
                    layer.close(index);
                });
            }
            //人员详情
            else if(layEvent === 'people'){
                layer.open({
                    type: 1 //Page层类型
                    ,area: ['100%', '100%']
                    ,title: '人员详情'
                    ,shade: 0.6 //遮罩透明度
                    ,maxmin: true //允许全屏最小化
                    ,content: '<div id="pensons" >' +
							'<button type="button" class="layui-btn layui-btn-sm sure">确认人员已到位</button>'+
							'<table class="layui-table fren" style="margin-top: 0px;">' +
							' <thead>\n' +
							'    <tr>\n' +
							'      <th rowspan="2">姓名</th>\n' +
							'      <th rowspan="2">岗位</th>\n' +
							'      <th rowspan="2">联系电话</th>\n' +
							'      <th rowspan="2">身份证号</th>\n' +
							'      <th class="zjNum" colspan="4">国际救援证件</th>\n' +
							'    </tr> \n' +
							'    <tr class="bt">\n' +
							'      <th>证件名称</th>\n' +
							'      <th>证件编号</th>\n' +
							'      <th>发证机构</th>\n' +
							'      <th>截止日期</th>\n' +
							'    </tr> \n' +
							'  </thead>'+
							'<tbody>'+
							'    <tr >\n' +
							'      <td></td>\n' +
							'      <td></td>\n' +
							'      <td></td>\n' +
							'      <td></td>\n' +
							'    </tr> \n' +
							'</tbody>'+
							'</table>' +
							'</div>'
                    ,btn: ['打印','导出PDF','取消']
                    ,yes: function(index, layero){
                        $('.layui-layer-btn').css('display','none')
                        window.print()
                        $('.layui-layer-btn').css('display','block')
                    }
                    ,btn2:function (index) {
                        var width =$('.layui-layer-content').width()
                        $.ajax({
                            url:'/crash/toPDF',
                            type:'post',
                            data:{
                                htmlContent:$('.bb').html(),
                                width:width
                            },
                            dataType:'json',
                            success:function (data){
                                var attUrl = data.object.attUrl;
                                window.open('/download?'+attUrl);
                            }
                        })
                        return false
                    }
                    ,success:function (res) {
                        var crasId=data.crasId;
                        var strs='';
						var flength=''
                        $.get('/crash/showDetails',{crasId:crasId, type:1},function (rese) {
                          // console.log(rese.obj)
							if(rese.obj.eventState==1){
								$('.sure').html('人员已确定')
								$('.sure').attr('disabled','true')
								$('.sure').addClass('no')

							}else if(rese.obj.eventState==0){
								$('.sure').html('确认人员到位')
							}
                            var fdata=rese.obj.rescuePersonList
							console.log(fdata)
							if(fdata==undefined){
								$('.sure').hide()
							}
                            var  str1= '<td>项目名称:</td>'+
                                '<td colspan="2">'+
                                function (){
                                    if(rese.obj.eventName==undefined){
                                        return  ''
                                    }else{
                                        return rese.obj.eventName
                                    }
                                }()+'</td> ' +
                                // '<td></td>'+
                                '<td>发生地点:</td>'+
                                '<td colspan="2" >'+
                                function (){
                                    if(rese.obj.happenPlace==undefined){
                                        return  ''
                                    }else{
                                        return rese.obj.happenPlace
                                    }
                                }()+'</td>' +
                                // '<td></td>'+
                                '<td>发生时间:</td>'+
                                '<td colspan="2">'+
                                function (){
                                    if(rese.obj.happenTime==undefined){
                                        return  ''
                                    }else{
                                        return rese.obj.happenTime
                                    }
                                }()+'</td>'+
                                // '<td></td>'+
                                '<td>事件描述:</td>'+
                                '<td colspan="2">'+
                                function (){
                                    if(rese.obj.eventDescribe==undefined){
                                        return  ''
                                    }else{
                                        return rese.obj.eventDescribe
                                    }
                                }()+'</td>'

                            for(var i=0;i<fdata.length;i++){
								strs+=' <tr>\n' +
										'      <td>'+fdata[i].userName+'</td>\n' +  //姓名
										'      <td>'+fdata[i].jobName+'</td>\n' +     //岗位
										'      <td>'+fdata[i].mobilNo+'</td>\n' +    //联系电话
										'      <td>'+fdata[i].idNumber+'</td>\n' +   //身份证号
										function () {
											var ss
											var zjbt
											 flength+=fdata[i].hrphotoWithBLOBsList.length+','
											if(fdata[i].hrphotoWithBLOBsList.length>0){
												for(var j=0;j<fdata[i].hrphotoWithBLOBsList.length;j++){
													zjbt+= '      <th>证件名称</th>\n' +
															'      <th>证件编号</th>\n' +
															'      <th>发证机构</th>\n' +
															'      <th>截止日期</th>\n'
													ss+='<td>'+function () {
																if(fdata[i].hrphotoWithBLOBsList[j].licenseName==undefined || fdata[i].hrphotoWithBLOBsList[j].licenseName==''){
																	return   ''
																}else{
																	return fdata[i].hrphotoWithBLOBsList[j].licenseName
																}
															}()+'</td>\n' +   //证件名称
															'      <td>'+fdata[i].hrphotoWithBLOBsList[j].licenseNo+'</td>\n' +  //证件编号
															'      <td>'+fdata[i].hrphotoWithBLOBsList[j].notifiedBody+'</td>\n' +   //发证机构
															'      <td>'+fdata[i].hrphotoWithBLOBsList[j].getLicenseDate+'</td>\n'   //取证日期

													$('.zjNum').attr('colspan',4*fdata[i].hrphotoWithBLOBsList.length)
												}
											}else{
												var chang=flength.split(',')
												var aa=chang.map(Number)
												var max = Math.max.apply(null,aa);
												console.log(max)
												if(max==0){
													ss+='<td></td>\n' +   //证件名称
															'<td></td>\n' +  //证件编号
															'<td></td>\n' +   //发证机构
															'<td></td>\n'   //取证日期
												}else {
													for(var k=0;k<max;k++){
														ss+='<td></td>\n' +   //证件名称
																'<td></td>\n' +  //证件编号
																'<td></td>\n' +   //发证机构
																'<td></td>\n'   //取证日期
													}
												}


											}


											$('.bt').html(zjbt)

											return ss
										}()+
										'    </tr>'
							}

							$('.tr_tds .renyuan').html(str1)
                            $('.fren tbody').html(strs)
                        });
						$('.sure').click(function () {
							$.ajax({
							url:'/crash/confirmUsers',
							type:'post',
							data:{
								type:1,
								crasId:crasId
							},
							dataType:'json',
							success:function (data){
								console.log(data)
								if(data.msg=true){
									$('.sure').html('人员已确定')
									$('.sure').attr('disabled','true')
									$('.sure').addClass('no')
								}
							}
						})
						})

                    }
                });

            }
            //物资详情
            else if(layEvent === 'thing'){
                //物资详情的页面
                layer.open({
                    type: 1 //Page层类型
                    ,area: ['100%', '100%']
                    ,title: '物资详情'
                    ,shade: 0.6 //遮罩透明度
                    ,maxmin: true //允许全屏最小化
                    ,content: '<div class="wz"><table id="fSettlement1" lay-filter="SettlementFilter"></table></div>'
                    ,btn: ['打印','导出PDF','取消']
                    ,yes: function(index, layero){
                        $('.layui-layer-btn').css('display','none')
                        window.print()
                        $('.layui-layer-btn').css('display','block')
                    }
                    ,btn2:function (index) {
                        // 获取表单的最长宽度
                        var width =$('.layui-layer-content').width()
                        $.ajax({
                            url:'/crash/toPDF',
                            type:'post',
                            data:{
                                htmlContent:$('.aa').html(),
                                width:width
                            },
                            dataType:'json',
                            success:function (data){
                                var attUrl = data.object.attUrl;
                                window.open('/download?'+attUrl);
                            }
                        })
                        return false
                    }
                    ,success:function (res) {
                        var crasId=data.crasId;
                        // console.log(crasId)
                        $.get('/crash/showDetails',{crasId:crasId, type:2},function (re) {
                            var data;
                            var  str1= '<td >'+'项目名称:'+
                                function (){
                                    if(re.obj.eventName==undefined){
                                        return  ''
                                    }else{
                                        return re.obj.eventName
                                    }
                                }()+'</td> ' +
                                '<td >'+'发生地点:'+
                                function (){
                                    if(re.obj.happenPlace==undefined){
                                        return  ''
                                    }else{
                                        return re.obj.happenPlace
                                    }
                                }()+'</td>' +
                                '<td>'+'发生时间:'+
                                function (){
                                    if(re.obj.happenTime==undefined){
                                        return  ''
                                    }else{
                                        return re.obj.happenTime
                                    }
                                }()+'</td>'+
                                '<td>'+'事件描述:'+
                                function (){
                                    if(re.obj.eventDescribe==undefined){
                                        return  ''
                                    }else{
                                        return re.obj.eventDescribe
                                    }
                                }()+'</td>'
                            if(re.obj.rescueEquipmentList!=undefined){
                                data=re.obj.rescueEquipmentList;
                            }else{
                                data=[]
                            }

                            var str = '';
                            var tab1=table.render({
                                elem: '#fSettlement1'
                                ,data:data
                                ,cols: [[
                                    {field:'assetsName', title:'设备名称',width:'20%'}
                                    ,{field:'info', title:'型号',width:'20%'}
                                    ,{field:'typeName', title:'设备类别',width:'20%'}
                                    ,{field:'currutLocation', title:'所在位置',width:'20%'}
                                    ,{field:'number', title:'数量',width:'20%'}
                                ]]
                                ,done:function (res) {
                                    for(var i=0;i<res.data.length;i++){
                                        str+='<tr>' +
                                            '<td style="text-align: center">'+res.data[i].assetsName+'</td> ' +
                                            '<td style="text-align: center">'+res.data[i].info+'</td>' +
                                            '<td style="text-align: center">'+res.data[i].typeName+'</td>' +
                                            '<td style="text-align: center">'+res.data[i].currutLocation+'</td>' +
                                            '<td style="text-align: center">'+res.data[i].number+'</td>' +
                                            '</tr>'
                                    }
                                    $('.tr_tds tbody').html(str);
                                    $('.tr_tds .wuzi').html(str1);

                                }
                                ,page: true,
                            })
                        });
                        $('.layui-table-view .layui-table').css('width','none')

                    }
                });
            }
		});

		var htmlpoen='<div>' +
				'			<form class="layui-form" action="">\n' +
				' <div class="layui-form-item" style="margin-top:10px">\n' +
				'<label class="layui-form-label">事件名称<b class="red">*</b>'+'</label>\n' +
				'<div class="layui-input-block">\n' +
				'<input type="text" name="eventName" id="information" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:50%">\n' +
				'</div>\n' +
				'</div>' +
				'<div class="layui-inline">\n' +
				'<label class="layui-form-label" style="margin-bottom:15px">发生时间<b class="red">*</b>'+'</label>\n' +
				'<div class="layui-input-inline">\n' +
				'<input type="datetime" name="happenTime" id="yzdata"  autocomplete="off" class="layui-input">\n' +
				'</div>\n'+
				'</div>' +
				'<div class="layui-form-item">\n' +
				'<label class="layui-form-label">发生地点<b class="red">*</b>'+'</label>\n' +
				'<div class="layui-input-block" style="margin-bottom:"15px">\n' +
				'<input type="text" name="happenPlace"  id="place" required  lay-verify="required"  autocomplete="off" class="layui-input" style="width:50%">\n' +
				'</div>'+
				'</div>\n' +
				'<div class="layui-inline" style="width:97%; margin: 15px 0;">\n' +
				'<label class="layui-form-label" style="width:68px;margin-top:-9px;margin-left:13px;">应急反应领导小组<b class="red">*</b>'+'</label>\n' +
				'<div class="layui-input-inline" style="width:72%">\n' +
				'<textarea type="text" id="rescueUser" name="rescueUserName"  autocomplete="off" class="layui-input" disabled></textarea>\n' +
				'<input type="hidden"  name="electivePerson" placeholder="" autocomplete="off" class="layui-input">\n'+
				'<div style="float:right;margin: -29px -72px 0px 0px;color:#1E9FFF"><a href="javascript:;" style="color:#1E9FFF" class="addjy">添加</a>\n' +
				'<a href="javascript:;" style="color:#1E9FFF" class="clear">清空</a>' +
				'</div>\n' +
				'</div>\n' +
				'</div>\n'+
				'<div class="layui-inline" style="width:97%; margin: 15px 0;">\n' +
				'<label class="layui-form-label" style="width:68px;margin-top:-9px;margin-left:13px;">应急反应执行小组<b class="red">*</b>'+'</label>\n' +
				'<div class="layui-input-inline" style="width:72%">\n' +
				'<textarea type="text" id="rescueExecute" name="rescueExecute"  autocomplete="off" class="layui-input" disabled></textarea>\n' +
				'<input type="hidden"  name="electivePerson" placeholder="" autocomplete="off" class="layui-input">\n'+
				'<div style="float:right;margin: -29px -72px 0px 0px;color:#1E9FFF"><a href="javascript:;" style="color:#1E9FFF" class="addExecute">添加</a>\n' +
				'<a href="javascript:;" style="color:#1E9FFF" class="clearExecute">清空</a>' +
				'</div>\n' +
				'</div>\n' +
				'</div>\n'+
				'<div class="layui-form-item layui-form-text">\n' +
				'<label class="layui-form-label">事件描述</label>\n' +
				'<div class="layui-input-block">\n' +
				'<textarea name="eventDescribe"  id="infoms" class="layui-textarea" style="width:81%"></textarea>\n' +
				'</div>\n' +
				'</div>\n' +
				'</form>' +
				'</div>'


		//点击添加救援事件
		$("#add").click(function(){
			layer.open({
				type: 1 //Page层类型
				,area: ['900px', '550px']
				,title: '添加救援事件'
				,shade: 0.6 //遮罩透明度
				,maxmin: true //允许全屏最小化
				,content: htmlpoen
				,btn: ['保存', '取消']
				,yes: function(index, layero){
					var info = $('#information').val()
					var yz = $('#yzdata').val()
					var dir = $('#place').val()
					var discr = $('#infoms').val()
					var user = $('#rescueUser').attr('username')
					var idss = $('#rescueUser').attr('dataid')
					var userExecute = $('#rescueExecute').attr('username')
					var idssExecute = $('#rescueExecute').attr('dataid')
					if(info==''){
						layer.msg('请填写事件名称！', {icon: 5});
						return false
					}
					if(yz==''){
						layer.msg('请填写发生时间！', {icon: 5});
						return false
					}
					if(dir==''){
						layer.msg('请填写发生地点！', {icon: 5});
						return false
					}
					if(user=='' || user==undefined){
						layer.msg('请选择应急反应领导小组！', {icon: 5});
						return false
					}
					if(userExecute=='' || userExecute==undefined){
						layer.msg('请选择应急反应执行小组！', {icon: 5});
						return false
					}
					param={
						eventName:info,
						happenTime:yz,
						happenPlace:dir,
						eventDescribe:discr,
						rescueUser:idss,
						rescueUserName:user,
						reactionUser:idssExecute,
						reactionUserName:userExecute
					},
							$.ajax({
								url:'/crashParent/add',
								type: 'post',
								dataType: 'json',
								data:param,
								success:function (res) {
                                    table.reload('idTest')
									layer.closeAll()
                                    window.location.reload()
								}
							});
					// layer.closeAll()
				}
				,success:function(e){
					$.ajax({
						url:'/crash/getLastDisp',
						type: 'post',
						dataType: 'json',
						success:function (res) {
							$('#rescueUser').val(res.obj.rescueUserName)
							$('#rescueUser').attr('username',res.obj.rescueUserName)
							$('#rescueUser').attr('dataid',res.obj.rescueUser)
							$('#rescueExecute').val(res.obj.reactionUserName)
							$('#rescueExecute').attr('username',res.obj.reactionUserName)
							$('#rescueExecute').attr('dataid',res.obj.reactionUser)
						}
					});
					//显示时间
					laydate.render({
						elem:'#yzdata'
						,trigger: 'click'//呼出事件改成click
						,type:'datetime'
						,format: 'yyyy-MM-dd HH:mm:ss'
						// value:new Date()
					});
					//点击添加的按钮
					$(".addjy").on("click",function(){
						user_id = "rescueUser";
						$.popWindow("/common/selectUser");
					});
					//点击清空的按钮
					$('.clear').click(function () {
						$("#rescueUser").val("");
						$("#rescueUser").attr('username','');
						$("#rescueUser").attr('dataid','');
						$("#rescueUser").attr('user_id','');
						$("#rescueUser").attr('userprivname','');
					});
					//点击添加的按钮
					$(".addExecute").on("click",function(){
						user_id = "rescueExecute";
						$.popWindow("/common/selectUser");
					});
					//点击清空的按钮
					$('.clearExecute').click(function () {
						$("#rescueExecute").val("");
						$("#rescueExecute").attr('username','');
						$("#rescueExecute").attr('dataid','');
						$("#rescueExecute").attr('user_id','');
						$("#rescueExecute").attr('userprivname','');
					});

				}
			});
		})
		function closex() {
			layer.closeAll()
		}
	})


	//时间戳转变日期格式 年-月-日 时-分-秒
	function timestampToTime1(timestamp) {
		var date = new Date(timestamp );//时间戳为10位需*1000，时间戳为13位的话不需乘1000
		var Y = date.getFullYear() + '-';
		var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
		var D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
		var h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
		var m = (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes()) + ':';
		var s = (date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds());
		return Y+M+D+h+m+s;
	}
</script>
</body>

</html>